//
//  CartoonCollectViewController.m
//  Double
//
//  Created by dllo on 15/5/25.
//  Copyright (c) 2015年 袁庆秋. All rights reserved.
//

#import "CartoonCollectViewController.h"
#import "CartoonCollectDatabase.h"
#import "CartoonCollectModel.h"


@interface CartoonCollectViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation CartoonCollectViewController

- (void)dealloc
{
    [super dealloc];
}
- (void)awakeFromNib
{
    [super awakeFromNib];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createView];
    // Do any additional setup after loading the view.
}

#pragma mark 创建TableView
- (void)createView
{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.separatorColor = [UIColor clearColor];
    [self.view addSubview:self.tableView];
    [self.tableView release];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.tableArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * cellInde = @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellInde];
    if (!cell) {
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellInde]autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    NSArray * array = [CartoonCollectDatabase selectAll];
    for (CartoonCollectModel * models in array) {
        NSString * CartoonId = [NSString stringWithFormat:@"%ld", models.CartoonId];
        NSString * CartoonName = models.CartoonName;
        cell.textLabel.text = CartoonName;
        cell.detailTextLabel.text = CartoonId;
        
    }
    
    return cell;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
